import java.text.DecimalFormat;
import java.util.Date;

import dti.DTIIndex;
import dti.Options;

/**
 * @author Andrew Bernard
 */
public class DTI {
  public static void main(String[] args) {
    try {
      System.out.println("Creating index ...");
      long start = new Date().getTime();
      Options options = new Options(args);
      DTIIndex index = new DTIIndex(options);
      String indexFilePath = index.write();
      long end = new Date().getTime();
      
      long creationTime = end - start;
      double creationTimeSecs = creationTime / 1000d;
      DecimalFormat decText = new DecimalFormat("0.00");
      System.out.println("Created index ("+ decText.format(creationTimeSecs)+" secs) at:\n"+indexFilePath);
      
//      DecimalFormat pctText = new DecimalFormat("##0.00%");
//      String indexCorpusRatio = pctText.format(index.getIndexCorpusRatio());
//      System.out.println("Index is "+indexCorpusRatio+" of corpus size."); 
    }
    catch (Throwable thr) {
//      thr.printStackTrace();
      System.err.println(thr.getMessage());
      System.exit(-1);
    }
  }
}